#!/usr/bin/perl

if ( $#ARGV < 0 ) {
    exit print "Usage ctunco element-name [...]\n" ;
}

$tool = $ENV{"DTOOL"} ;
if ( $tool eq "" ) {
    die "not configured for using CTtools" ;
}

require "$tool/built/include/ctutils.pl" ;
require "$tool/built/include/ctvspec.pl" ;
require "$tool/built/include/ctquery.pl" ;
require "$tool/built/include/ctproj.pl" ;
require "$tool/built/include/ctcm.pl" ;

$projname = &CTProj ;
$projname =~ tr/A-Z/a-z/ ;
$flav = &CTQueryProj( $projname ) ;
$spec = &CTResolveSpec( $projname, $flav ) ;

foreach $item ( @ARGV ) {
    if ( -e $item ) {
	if ( ! &CTCMUncheckout( $item, $projname, $spec ) ) {
	    print STDERR "Could not uncheckout '$item'\n" ;
	}
    } else {
	print STDERR "No such file '$item'.\n" ;
    }
}
